class Solution {
public:
    vector<int> supplyWagon(vector<int>& a)
    {
        int m = a.size() / 2;
        while (a.size() > m) {
            int j = 1;
            for (int i = 1; i < a.size(); ++i)
                if (a[i] + a[i - 1] < a[j] + a[j - 1])
                    j = i;
            a[j - 1] += a[j];
            a.erase(a.begin() + j);
        }
        return a;
    }
};